<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s_plan" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="productionPlanUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/mes/produce/DetailsPlan?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 计划详情 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="标题" prop="plan_title">
                  <el-input v-model="s_plan.plan_title" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="产品名称" prop="product_id">
                  {{s_plan.product_id}}
                  <el-button @click="popProductSelection1('product_id','product_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="产品数量" prop="product_num">
                  <el-input v-model="s_plan.product_num" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="计划负责人" prop="plan_charge">
                  {{s_plan.plan_charge}}
                  <el-button @click="popSelectionOfficerCurrency('plan_charge','plan_charge')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="begin_time">
                  <el-date-picker v-model="s_plan.begin_time" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="完成时间" prop="com_time">
                  <el-date-picker v-model="s_plan.com_time" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="计划说明" prop="plan_explain">
                  <el-input type="textarea" v-model="s_plan.plan_explain" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="remark">
                  <el-input type="textarea" v-model="s_plan.remark" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'计划明细'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="ProductSelection1Visible" append-to-body>
      <ProductSelection1 v-if="ProductSelection1Visible" ref="ProductSelection1" :popparams="popparams"> </ProductSelection1>
    </el-dialog>
    <el-dialog :visible.sync="SelectionOfficerCurrencyVisible" append-to-body>
      <SelectionOfficerCurrency v-if="SelectionOfficerCurrencyVisible" ref="SelectionOfficerCurrency" :popparams="popparams"> </SelectionOfficerCurrency>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ProductSelection1 from "@/views/mes/supplychainmana/ProductSelection1";
  import SelectionOfficerCurrency from "@/views/mes/autooffice/SelectionOfficerCurrency";
  export default {
    name: 'ProductionPlanUp',
    components: {
      ProductSelection1,
      SelectionOfficerCurrency,
    },
    props: ['popparams'],
    data() {
      return {
        ProductSelection1Visible: false,
        ProductSelection1Value: null,
        ProductSelection1Desc: null,
        SelectionOfficerCurrencyVisible: false,
        SelectionOfficerCurrencyValue: null,
        SelectionOfficerCurrencyDesc: null,
        vueparams: this.getVUEParams(""),
        s_plan: {
          plan_title: null,
          product_id: null,
          product_num: null,
          plan_charge: null,
          begin_time: null,
          com_time: null,
          plan_explain: null,
          remark: null,
        },
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "3FB71F06EF24449EA08DAA333F42CD9C",
        name: "生产物料右菜单",
        selected: "计划明细"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/DetailsPlanAction/productionPlanUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      productionPlanUpSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/DetailsPlanAction/productionPlanUpSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/produce/DetailsPlan/detailsPlan?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popProductSelection1(desc, value) {
        this.ProductSelection1Visible = true;
        this.ProductSelection1Desc = desc;
        this.ProductSelection1Value = value;
      },
      closeProductSelection1(value, desc) {
        this.ProductSelection1Visible = false;
        this.$set(this.s_plan, this.ProductSelection1Desc, desc);
        this.$set(this.s_plan, this.ProductSelection1Value, value);
      },
      popSelectionOfficerCurrency(desc, value) {
        this.SelectionOfficerCurrencyVisible = true;
        this.SelectionOfficerCurrencyDesc = desc;
        this.SelectionOfficerCurrencyValue = value;
      },
      closeSelectionOfficerCurrency(value, desc) {
        this.SelectionOfficerCurrencyVisible = false;
        this.$set(this.s_plan, this.SelectionOfficerCurrencyDesc, desc);
        this.$set(this.s_plan, this.SelectionOfficerCurrencyValue, value);
      },
    },
  }
</script>
